Skip to content

object-curly-spacing#21

Closed
eddiemoore wants to merge 1 commit intostandard:masterfrom
eddiemoore:patch-1
Closed

object-curly-spacing#21
eddiemoore wants to merge 1 commit intostandard:masterfrom
eddiemoore:patch-1

Conversation

@eddiemoore
Copy link
Copy Markdown

Require a space at the start and end of objects.
Valid:

var obj = {};
var obj = { 'foo': 'bar' };
var obj = { 'foo': { 'bar': 'baz' }, 'qux': 'quxx' };
var obj = {
  'foo': 'bar'
};
var { x } = y;
import { foo } from 'bar';

Invalid

var obj = {'foo': 'bar'};
var obj = {'foo': 'bar' };
var obj = { baz: {'foo': 'qux'}, bar};
var obj = {baz: { 'foo': 'qux' }, bar};
var obj = {'foo': 'bar'
};
var obj = {
  'foo':'bar'};
var {x} = y;
import {foo } from 'bar';

Require a space at the start and end of objects.
Valid:
```js
var obj = {};
var obj = { 'foo': 'bar' };
var obj = { 'foo': { 'bar': 'baz' }, 'qux': 'quxx' };
var obj = {
  'foo': 'bar'
};
var { x } = y;
import { foo } from 'bar';
```

Invalid
```js
var obj = {'foo': 'bar'};
var obj = {'foo': 'bar' };
var obj = { baz: {'foo': 'qux'}, bar};
var obj = {baz: { 'foo': 'qux' }, bar};
var obj = {'foo': 'bar'
};
var obj = {
  'foo':'bar'};
var {x} = y;
import {foo } from 'bar';
```
@julien-f
Copy link
Copy Markdown

What about arrays?
Shouldn't it have the same behavior?

@julien-f
Copy link
Copy Markdown

And this is a major change, standard would be bumped to v6.

@dcousens
Copy link
Copy Markdown
Member

AFAIK this is already meant to be enforced, if this isn't the case, it's a bug IIRC.

@dcousens dcousens added the bug label Jan 22, 2016
@dcousens
Copy link
Copy Markdown
Member

Reference standard/standard#182, this is out lined as what we expected.

@feross looks good to me? Merge?

@eddiemoore
Copy link
Copy Markdown
Author

I know there is the even spacing rule at the moment, however it can mean that you aren't consistent across all objects in all files.

var x = { y: 42 }
var z = {p: 24}

This for example, would be valid at the moment. I just feel that it should be consistent spacing across everything.

@dcousens dcousens removed the bug label Jan 22, 2016
@dcousens
Copy link
Copy Markdown
Member

Ah, that is the key point of difference.

@feross
Copy link
Copy Markdown
Member

feross commented Feb 5, 2016

Yeah, this is a big breaking change. We investigated how easy it would be to make things consistent across a single file, but it wasn't easy.

In the future, I'm hoping we can just pick var x = { y: 42 } as the correct style, but we need to think about the implications of breakage.

@feross feross closed this Feb 5, 2016
@dcousens
Copy link
Copy Markdown
Member

dcousens commented Feb 5, 2016

@feross where were those stats again?
Any chance we can see where they sit now for a rule change such as this?

@feross
Copy link
Copy Markdown
Member

feross commented Feb 5, 2016

I ran it a while ago. I can re-run, but I know it's going to be too high (double digit percentages) to get into standard v6. I think we should punt until v7, or this release is going to get too huge.

@mightyiam
Copy link
Copy Markdown
Contributor

Continue conversation @ Object curlies: File/project–wide or standard?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants